<!-- 设备 》 设备台账 -->

<template>
  <CommonBody
    hasTree
    :tree="$root.device_category_tree"
    :field="$root.device_category_TREE_FIELD"
    bind="assetTypeId"
    filterTip="分类名称"
    hasReset
    @change="startList(1)"
  >
    <template #search>
      <MySearch />
    </template>

    <template #table>
      <MyTable />
    </template>

    <MyModal />

    <DealModal />

    <IOTModal />

    <ImportModal :progress="upProgress" @download="startDownload" @upload="startUpload" />
  </CommonBody>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import store from './store'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'DeviceList',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixStore(store)],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 监听属性 (深度 deep 首次 immediate)
   */
  watch: {
    /**
     * 监听弹窗关闭
     */
    visible(visible) {
      if (!visible && this.INIT_CONFIG.SUBMIT_KEEP_VISIBLE) this.INIT_CONFIG.SUBMIT_KEEP_VISIBLE = false
    },

    /**
     * 监听处理就绪
     */
    deal_readyEdit(ready) {
      ready && this.startList()
      ready && this.visible && this.startOne()
    },

    /**
     * 监听 IOT 导入就绪
     */
    iot_readyAdd(ready) {
      ready && this.startList(1)
    },

    /**
     * 监听资产分类切换
     */
    'one.assetTypeId'() {
      !this.isShow && this.property_startSelect()
    },

    /**
     * 监听 IOT 导入的资产分类切换
     */
    'iot_one.assetTypeId'() {
      this.property_startSelect()
    },
  },
}
</script>
